<?php
	

	/**
	 * SystemMail
	 * @package Core
	 * @author Otavio Theiss - iperfly@gmail.com
	 * @copyright 15/08/2010
	 */
	class CoreMail extends PHPMailer {
		
		/**
		 * Contrutor para envio de emails
		 *
		 * @param string $subject
		 * @param string $body
		 * @param string $to
		 * @param bool $send
		 */
		public function __construct($subject = "", $body = "", $to = "", $send = false,$isHTML = true) {
			$this->Host			= CoreDefault::$PhpmailerHost;
			$this->Port 		= CoreDefault::$PhpmailerPort;
			$this->Mailer 		= CoreDefault::$PhpmailerMailer;
			$this->SMTPAuth		= CoreDefault::$PhpmailerSMTPAuth;
			$this->Username 	= CoreDefault::$PhpmailerUsername;
			$this->Password 	= CoreDefault::$PhpmailerPassword;
			$this->From 		= CoreDefault::$PhpmailerFrom;
			$this->FromName		= CoreDefault::$PhpmailerFromName;
			$this->IsHTML($isHTML);
			if ($subject)
				$this->Subject = $subject;
			if ($body)
				$this->Body = $body;
			if ($to) {
				if (!is_array($to))
					$to = explode(";", $to);
				foreach($to as $value)
					$this->AddAddress($value);					
			}
			if ($send){
				$this->Send();
				$this->ClearAllRecipients();
			}
		}
		
		/**
		 * Verifica se o e-mail foi enviado
		 *
		 * @return bool
		 */
		public function isSend() {
			return (!$this->IsError());
		}
	}
?>